package JLB_Chapter_02;

// ImplicitConversion

public class code_02_07 {
    public static void main(String[] args) {
        // 将int类型的变量赋值给float类型变量
        int x = 50;
        float y = x;
        System.out.println(y);
        // 声明byte类型变量mybyte,并把byte类型变量允许的最大值赋给mybyte
        byte mybyte = 127;
        int myint = 150;
        float myfloat = 452.12f;
        //
        char mychar = 97;
        double mydouble = 45.46546;
        // 输出运算结果
        System.out.println(mychar);
        System.out.println("byte类型与float类型数据进行运算结果为：" + (mybyte + myfloat));
        System.out.println("byte类型与int类型数据进行运算结果为：" + (mybyte * myint));
        System.out.println("byte类型与char类型数据进行运算结果为：" + (mybyte + mychar));
        System.out.println("double类型与char类型数据进行运算结果为：" + (mydouble + mychar));
        // String对象转换成为int类型
        String a = "700000";
        int b = Integer.parseInt(a);
        System.out.println(b);
        double c = Double.parseDouble(a);
        System.out.println(c);
        // int类型转换成为String对象
        int i = 15;
        String s1 = String.valueOf(i);
        System.out.println(s1);
        String s2 = Integer.toString(i);
        System.out.println(s2);
        String s3 = "" + i;
        System.out.println(s3);
    }
}
